﻿using Acme.BookStore.FormWhxDto.BinlocationDto;
using Acme.BookStore.FormWhxDto.StorehouseDto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace Acme.BookStore.Controllers
{
    [RemoteService]
    [Route("api/app/storehouse")]
    [ApiController]
    public class StorehouseController : ControllerBase
    {
        private readonly IStorehouseService _storehouseService;

        public StorehouseController(IStorehouseService storehouseService)
        {
            _storehouseService = storehouseService;
        }

        [HttpGet("search")]
        public async Task<PagedResultDto<StorehouseDto>> SearchAsync([FromQuery] StorehouseSearchDto input)
        {
            return await _storehouseService.SearchAsync(input);
        }

        [HttpPost("storehouse-with-locations")]
        public async Task<IActionResult> StorehouseWithLocations([FromBody] FormWhxDto.StorehouseDto.CreateUpdateStorehouseWithLocationsDto input)
        {
            await _storehouseService.AddSorehouseWithLocations(input);
            return Ok();
        }
    }
}
